import 'package:flutter/material.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class HomeCard extends StatelessWidget {
  final void Function()? onTap;
  final String title;
  final String subTitle;
  final String rightImageUrl;
  const HomeCard(
      {super.key,
      this.title = '',
      this.subTitle = '',
      this.rightImageUrl = '',
      this.onTap});

  Widget get content {
    return Padding(
        padding: EdgeInsets.fromLTRB(15.0.w, 10.0.h, 15.0.w, 10.0.h),
        child:
            Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
          Expanded(
              flex: 76,
              child: Column(
                  mainAxisAlignment: MainAxisAlignment.start,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text(title,
                        style: TextStyle(
                            fontSize: 18.0.sp, fontWeight: FontWeight.bold)),
                    const SizedBox(height: 10.0),
                    Text(subTitle,
                        style: TextStyle(color: Colors.grey,
                            fontSize: 14.0.sp, fontWeight: FontWeight.normal))
                  ])),
          const Spacer(flex: 4),
          Expanded(
              flex: 20,
              child: Container(
                  height: 72.0.w,
                  decoration: BoxDecoration(
                      image: DecorationImage(
                          image: CachedNetworkImageProvider(rightImageUrl),
                          fit: BoxFit.cover),
                      borderRadius: BorderRadius.circular(4.0.w))))
        ]));
  }

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
        onTap: onTap, behavior: HitTestBehavior.opaque, child: content);
  }
}
